package com.zhaosoft;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;

/**
 * 快速入门
 *
 * @author 翟永超
 * @create 2016/11/8.
 * @blog http://blog.didispace.com
 */
@EnableBinding(value = { Sink.class })
public class SinkReceiver {

	private static Logger logger = LoggerFactory.getLogger(SinkReceiver.class);

	// @StreamListener(Sink.INPUT)
	// public void receive(Object payload) {
	// logger.info("Received: " + payload);
	// }

	// @ServiceActivator(inputChannel = Sink.INPUT)
	// public void receive(User user) {
	// logger.info("Received: " + user);
	// }
	//
	// @Transformer(inputChannel = Sink.INPUT, outputChannel = Sink.INPUT)
	// public User transform(String message) throws Exception {
	// ObjectMapper objec七Mapper = new ObjectMapper();
	// User user = objec七Mapper.readValue(message, User.class);
	// return user;
	// }

	@StreamListener(Sink.INPUT)
	public void receive(User user) {
		logger.info("Received: " + user);
	}

}
